<?php
/**
 * Nad�b (Mak�-Nad�b)
 *
 * @filesource 
 * @copyright  Copyright 2010 mateusweb.com.br
 * @license    Freeware
 * @package    Nadeb_Controller
 * @subpackage Nadeb.Controller
 * @version    1.0
 */

class Nadeb_Controller_Models
{
	public static function save($params,$type = "basic")
	{
		$model  = '';
		$model .= '/**' . "\n";
		$model .= ' * Modelo da classe ' . $params['name_class'] . '' . "\n";
		$model .= ' * @filesource' . "\n"; 
		$model .= ' * @author       Mateus Reis Martins' . "\n";
		$model .= ' * @subpackage   user.app.models' . "\n";
		$model .= ' * @version      1.1' . "\n";
		$model .= ' */' . "\n";
		$model .= '' . "\n";
		$model .= 'class Admin_Models_' . $params['name_class'] . ' extends Nadeb_Model' . "\n";
		$model .= '{' . "\n";
		$model .= '	protected $_name      = "'. $params["tb_name"] .'";' . "\n";
		$model .= '	protected $_primary   = "'. $params["id_name"] .'";' . "\n";
		$model .= '	protected $_activeCol = "'. $params["prefix_col"] .'_active";' . "\n";
		
		$model .= call_user_func( array( "Nadeb_Controller_Models", $type ), $params );
		//$model .= Nadeb_Controller_Models::basic($params);
	
		$model .= '}' . "\n";		

		Nadeb_Savefile::save($_SERVER['DOCUMENT_ROOT'] . '/application/modules/Admin/Models/' . $params['name_class'] . '.php', '<?php' . "\n" . $model);
	}
	
	private static function basic($params)
	{
		$model  = '';
		
		return $model;
	}
}